<img name="animation" src="images/te1.jpg">
<script>
var aniframes = new Array(4);
for(var i = 1; i < 5; i++)
{
    aniframe[i] = new Image();
    aniframe[i].src = "images/te" + i + ".jpg";
}

var n = 1;
var timeout_id = null;

function animate()
{
    document.animation.src = aniframes[n].src;
    n = (n + 1)%4;
    timeout_id = setTimeout("animate()", 50);
}
</script>

<form>
    <input type="button" value="start"
     onclick="if (timeout_id== null) animate();">
</form>
